import java.util.ArrayList;

public class StartGame {
	public ArrayList<Ship> start() {
		System.out.println("Let's start the game!");
		int plot = 10;
		ArrayList<Ship> ships = new ArrayList<Ship>();
		for (int i = 1; i <= 4; i++) {

			for (int j = 1; j <= i; j++) {

				int hor = Math.abs((int) (Math.random() * (plot - 5 + i + 1)));
				int ver = Math.abs((int) (Math.random() * (plot - 5 + i + 1)));
				boolean orient = (Math.random() >= 0.5);
				if (!ships.isEmpty()) {
					for (Ship a : ships) {
						while (cross(a, new Ship(5 - i, hor, ver, orient))) {
							hor = Math
									.abs((int) (Math.random() * (plot - 5 + i + 1)));
							ver = Math
									.abs((int) (Math.random() * (plot - 5 + i + 1)));
							orient = (Math.random() >= 0.5);
						}

					}
				}
				Ship ship = new Ship(5 - i, hor, ver, orient);
				ships.add(ship);

				for (Coord a : ship.getPos()) {
					System.out.println(" " + ship.getSize() + " " + a.getHor()
							+ " " + a.getVer() + " " + ship.getHor());
				}

			}

		}
		return ships;

	}

	public boolean cross(Ship a, Ship b) {
		for (Coord i : b.getPos()) {
			if (a.getPos().contains(i)) {
				return true;
			}

		}
		return false;
	}
}
